package b.b.e.a;

import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.annotation.SuppressLint;
import android.content.res.Resources;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.util.StateSet;
import b.f.i;

@SuppressLint({"RestrictedAPI"})
/* compiled from: AnimatedStateListDrawableCompat */
public class a extends d implements b.i.d.l.a {
    public c p;
    public g q;
    public int r;
    public int s;
    public boolean t;

    /* compiled from: AnimatedStateListDrawableCompat */
    public static class f implements TimeInterpolator {
        public int[] a;
        public int b;
        public int c;

        public f(AnimationDrawable animationDrawable, boolean z) {
            int numberOfFrames = animationDrawable.getNumberOfFrames();
            this.b = numberOfFrames;
            int[] iArr = this.a;
            if (iArr == null || iArr.length < numberOfFrames) {
                this.a = new int[numberOfFrames];
            }
            iArr = this.a;
            int i = 0;
            for (int i2 = 0; i2 < numberOfFrames; i2++) {
                int duration = animationDrawable.getDuration(z ? (numberOfFrames - i2) - 1 : i2);
                iArr[i2] = duration;
                i += duration;
            }
            this.c = i;
        }

        public float getInterpolation(float f) {
            int i = (int) ((f * ((float) this.c)) + 0.5f);
            int i2 = this.b;
            int[] iArr = this.a;
            int i3 = 0;
            while (i3 < i2 && i >= iArr[i3]) {
                i -= iArr[i3];
                i3++;
            }
            return (((float) i3) / ((float) i2)) + (i3 < i2 ? ((float) i) / ((float) this.c) : 0.0f);
        }
    }

    /* compiled from: AnimatedStateListDrawableCompat */
    public static abstract class g {
        public g(a aVar) {
        }

        public boolean a() {
            return false;
        }

        public void b() {
        }

        public abstract void c();

        public abstract void d();
    }

    /* compiled from: AnimatedStateListDrawableCompat */
    public static class b extends g {
        public final Animatable a;

        public b(Animatable animatable) {
            super(null);
            this.a = animatable;
        }

        public void c() {
            this.a.start();
        }

        public void d() {
            this.a.stop();
        }
    }

    /* compiled from: AnimatedStateListDrawableCompat */
    public static class d extends g {
        public final b.s.a.a.b a;

        public d(b.s.a.a.b bVar) {
            super(null);
            this.a = bVar;
        }

        public void c() {
            this.a.start();
        }

        public void d() {
            this.a.stop();
        }
    }

    /* compiled from: AnimatedStateListDrawableCompat */
    public static class e extends g {
        public final ObjectAnimator a;
        public final boolean b;

        public e(AnimationDrawable animationDrawable, boolean z, boolean z2) {
            super(null);
            int numberOfFrames = animationDrawable.getNumberOfFrames();
            int i = z ? numberOfFrames - 1 : 0;
            numberOfFrames = z ? 0 : numberOfFrames - 1;
            f fVar = new f(animationDrawable, z);
            ObjectAnimator ofInt = ObjectAnimator.ofInt(animationDrawable, "currentIndex", new int[]{i, numberOfFrames});
            ofInt.setAutoCancel(true);
            ofInt.setDuration((long) fVar.c);
            ofInt.setInterpolator(fVar);
            this.b = z2;
            this.a = ofInt;
        }

        public boolean a() {
            return this.b;
        }

        public void b() {
            this.a.reverse();
        }

        public void c() {
            this.a.start();
        }

        public void d() {
            this.a.cancel();
        }
    }

    /* compiled from: AnimatedStateListDrawableCompat */
    public static class c extends b.b.e.a.d.a {
        public b.f.e<Long> K;
        public i<Integer> L;

        public c(c cVar, a aVar, Resources resources) {
            super(cVar, aVar, resources);
            if (cVar != null) {
                this.K = cVar.K;
                this.L = cVar.L;
                return;
            }
            this.K = new b.f.e(10);
            this.L = new i(10);
        }

        public static long h(int i, int i2) {
            return ((long) i2) | (((long) i) << 32);
        }

        public void e() {
            this.K = this.K.clone();
            this.L = this.L.clone();
        }

        public int i(int i) {
            return i < 0 ? 0 : ((Integer) this.L.e(i, Integer.valueOf(0))).intValue();
        }

        public Drawable newDrawable() {
            return new a(this, null);
        }

        public Drawable newDrawable(Resources resources) {
            return new a(this, resources);
        }
    }

    static {
        Class cls = a.class;
    }

    public a() {
        this(null, null);
    }

    /* JADX WARNING: Missing block: B:77:0x01f8, code skipped:
            throw new org.xmlpull.v1.XmlPullParserException(c.b.a.a.a.f(r2, new java.lang.StringBuilder(), ": <transition> tag requires 'fromId' & 'toId' attributes"));
     */
    public static b.b.e.a.a g(android.content.Context r19, android.content.res.Resources r20, org.xmlpull.v1.XmlPullParser r21, android.util.AttributeSet r22, android.content.res.Resources.Theme r23) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException {
        /*
        r0 = r19;
        r1 = r20;
        r2 = r21;
        r3 = r22;
        r4 = r23;
        r5 = r21.getName();
        r6 = "animated-selector";
        r6 = r5.equals(r6);
        if (r6 == 0) goto L_0x021e;
    L_0x0016:
        r5 = new b.b.e.a.a;
        r6 = 0;
        r5.m7834init(r6, r6);
        r7 = b.b.f.a.a;
        r7 = b.i.c.b.h.e(r1, r4, r3, r7);
        r8 = 1;
        r9 = r7.getBoolean(r8, r8);
        r5.setVisible(r9, r8);
        r9 = r5.p;
        r10 = r9.d;
        r11 = r7.getChangingConfigurations();
        r10 = r10 | r11;
        r9.d = r10;
        r10 = r9.i;
        r11 = 2;
        r10 = r7.getBoolean(r11, r10);
        r9.i = r10;
        r10 = r9.l;
        r12 = 3;
        r10 = r7.getBoolean(r12, r10);
        r9.l = r10;
        r10 = r9.A;
        r13 = 4;
        r10 = r7.getInt(r13, r10);
        r9.A = r10;
        r10 = 5;
        r14 = r9.B;
        r10 = r7.getInt(r10, r14);
        r9.B = r10;
        r9 = r9.x;
        r10 = 0;
        r9 = r7.getBoolean(r10, r9);
        r5.setDither(r9);
        r9 = r5.a;
        r9.f(r1);
        r7.recycle();
        r7 = r21.getDepth();
        r7 = r7 + r8;
    L_0x0070:
        r9 = r21.next();
        if (r9 == r8) goto L_0x0216;
    L_0x0076:
        r14 = r21.getDepth();
        if (r14 >= r7) goto L_0x007e;
    L_0x007c:
        if (r9 == r12) goto L_0x0216;
    L_0x007e:
        if (r9 == r11) goto L_0x0081;
    L_0x0080:
        goto L_0x0070;
    L_0x0081:
        if (r14 <= r7) goto L_0x0084;
    L_0x0083:
        goto L_0x0070;
    L_0x0084:
        r9 = r21.getName();
        r11 = "item";
        r9 = r9.equals(r11);
        r11 = -1;
        if (r9 == 0) goto L_0x013d;
    L_0x0091:
        r9 = b.b.f.a.b;
        r9 = b.i.c.b.h.e(r1, r4, r3, r9);
        r12 = r9.getResourceId(r10, r10);
        r8 = r9.getResourceId(r8, r11);
        if (r8 <= 0) goto L_0x00a9;
    L_0x00a1:
        r6 = b.b.h.v.d();
        r6 = r6.f(r0, r8);
    L_0x00a9:
        r9.recycle();
        r8 = r22.getAttributeCount();
        r9 = new int[r8];
        r11 = 0;
        r14 = 0;
    L_0x00b4:
        if (r11 >= r8) goto L_0x00da;
    L_0x00b6:
        r15 = r3.getAttributeNameResource(r11);
        r16 = r7;
        if (r15 == 0) goto L_0x00d5;
    L_0x00be:
        r7 = 16842960; // 0x10100d0 float:2.369414E-38 double:8.321528E-317;
        if (r15 == r7) goto L_0x00d5;
    L_0x00c3:
        r7 = 16843161; // 0x1010199 float:2.3694704E-38 double:8.321627E-317;
        if (r15 == r7) goto L_0x00d5;
    L_0x00c8:
        r7 = r14 + 1;
        r17 = r3.getAttributeBooleanValue(r11, r10);
        if (r17 == 0) goto L_0x00d1;
    L_0x00d0:
        goto L_0x00d2;
    L_0x00d1:
        r15 = -r15;
    L_0x00d2:
        r9[r14] = r15;
        r14 = r7;
    L_0x00d5:
        r11 = r11 + 1;
        r7 = r16;
        goto L_0x00b4;
    L_0x00da:
        r16 = r7;
        r7 = android.util.StateSet.trimStateSet(r9, r14);
        r8 = ": <item> tag requires a 'drawable' attribute or child tag defining a drawable";
        if (r6 != 0) goto L_0x0113;
    L_0x00e4:
        r6 = r21.next();
        if (r6 != r13) goto L_0x00eb;
    L_0x00ea:
        goto L_0x00e4;
    L_0x00eb:
        r9 = 2;
        if (r6 != r9) goto L_0x0104;
    L_0x00ee:
        r6 = r21.getName();
        r9 = "vector";
        r6 = r6.equals(r9);
        if (r6 == 0) goto L_0x00ff;
    L_0x00fa:
        r6 = b.s.a.a.f.a(r20, r21, r22, r23);
        goto L_0x0113;
    L_0x00ff:
        r6 = android.graphics.drawable.Drawable.createFromXmlInner(r20, r21, r22, r23);
        goto L_0x0113;
    L_0x0104:
        r0 = new org.xmlpull.v1.XmlPullParserException;
        r1 = new java.lang.StringBuilder;
        r1.<init>();
        r1 = c.b.a.a.a.f(r2, r1, r8);
        r0.<init>(r1);
        throw r0;
    L_0x0113:
        if (r6 == 0) goto L_0x012e;
    L_0x0115:
        r8 = r5.p;
        r6 = r8.a(r6);
        r9 = r8.J;
        r9[r6] = r7;
        r7 = r8.L;
        r8 = java.lang.Integer.valueOf(r12);
        r7.g(r6, r8);
        r6 = 0;
        r8 = 1;
        r11 = 2;
        r12 = 3;
        goto L_0x0212;
    L_0x012e:
        r0 = new org.xmlpull.v1.XmlPullParserException;
        r1 = new java.lang.StringBuilder;
        r1.<init>();
        r1 = c.b.a.a.a.f(r2, r1, r8);
        r0.<init>(r1);
        throw r0;
    L_0x013d:
        r16 = r7;
        r6 = r21.getName();
        r7 = "transition";
        r6 = r6.equals(r7);
        if (r6 == 0) goto L_0x0208;
    L_0x014b:
        r6 = b.b.f.a.c;
        r6 = b.i.c.b.h.e(r1, r4, r3, r6);
        r7 = 2;
        r7 = r6.getResourceId(r7, r11);
        r8 = 1;
        r8 = r6.getResourceId(r8, r11);
        r9 = r6.getResourceId(r10, r11);
        if (r9 <= 0) goto L_0x016a;
    L_0x0161:
        r12 = b.b.h.v.d();
        r9 = r12.f(r0, r9);
        goto L_0x016b;
    L_0x016a:
        r9 = 0;
    L_0x016b:
        r12 = 3;
        r10 = r6.getBoolean(r12, r10);
        r6.recycle();
        r6 = ": <transition> tag requires a 'drawable' attribute or child tag defining a drawable";
        if (r9 != 0) goto L_0x01ab;
    L_0x0177:
        r9 = r21.next();
        if (r9 != r13) goto L_0x017e;
    L_0x017d:
        goto L_0x0177;
    L_0x017e:
        r12 = 2;
        if (r9 != r12) goto L_0x019c;
    L_0x0181:
        r9 = r21.getName();
        r12 = "animated-vector";
        r9 = r9.equals(r12);
        if (r9 == 0) goto L_0x0197;
    L_0x018d:
        r9 = new b.s.a.a.b;
        r12 = 0;
        r9.m7872init(r0, r12, r12);
        r9.inflate(r1, r2, r3, r4);
        goto L_0x01ab;
    L_0x0197:
        r9 = android.graphics.drawable.Drawable.createFromXmlInner(r20, r21, r22, r23);
        goto L_0x01ab;
    L_0x019c:
        r0 = new org.xmlpull.v1.XmlPullParserException;
        r1 = new java.lang.StringBuilder;
        r1.<init>();
        r1 = c.b.a.a.a.f(r2, r1, r6);
        r0.<init>(r1);
        throw r0;
    L_0x01ab:
        if (r9 == 0) goto L_0x01f9;
    L_0x01ad:
        if (r7 == r11) goto L_0x01e8;
    L_0x01af:
        if (r8 == r11) goto L_0x01e8;
    L_0x01b1:
        r6 = r5.p;
        r9 = r6.a(r9);
        r11 = b.b.e.a.a.c.h(r7, r8);
        if (r10 == 0) goto L_0x01c3;
    L_0x01bd:
        r13 = 8589934592; // 0x200000000 float:0.0 double:4.243991582E-314;
        goto L_0x01c5;
    L_0x01c3:
        r13 = 0;
    L_0x01c5:
        r15 = r6.K;
        r0 = (long) r9;
        r17 = r0 | r13;
        r9 = java.lang.Long.valueOf(r17);
        r15.a(r11, r9);
        if (r10 == 0) goto L_0x0208;
    L_0x01d3:
        r7 = b.b.e.a.a.c.h(r8, r7);
        r6 = r6.K;
        r9 = 4294967296; // 0x100000000 float:0.0 double:2.121995791E-314;
        r0 = r0 | r9;
        r0 = r0 | r13;
        r0 = java.lang.Long.valueOf(r0);
        r6.a(r7, r0);
        goto L_0x0208;
    L_0x01e8:
        r0 = new org.xmlpull.v1.XmlPullParserException;
        r1 = new java.lang.StringBuilder;
        r1.<init>();
        r3 = ": <transition> tag requires 'fromId' & 'toId' attributes";
        r1 = c.b.a.a.a.f(r2, r1, r3);
        r0.<init>(r1);
        throw r0;
    L_0x01f9:
        r0 = new org.xmlpull.v1.XmlPullParserException;
        r1 = new java.lang.StringBuilder;
        r1.<init>();
        r1 = c.b.a.a.a.f(r2, r1, r6);
        r0.<init>(r1);
        throw r0;
    L_0x0208:
        r6 = 0;
        r8 = 1;
        r10 = 0;
        r11 = 2;
        r12 = 3;
        r13 = 4;
        r0 = r19;
        r1 = r20;
    L_0x0212:
        r7 = r16;
        goto L_0x0070;
    L_0x0216:
        r0 = r5.getState();
        r5.onStateChange(r0);
        return r5;
    L_0x021e:
        r0 = new org.xmlpull.v1.XmlPullParserException;
        r1 = new java.lang.StringBuilder;
        r1.<init>();
        r2 = r21.getPositionDescription();
        r1.append(r2);
        r2 = ": invalid animated-selector tag ";
        r1.append(r2);
        r1.append(r5);
        r1 = r1.toString();
        r0.<init>(r1);
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: b.b.e.a.a.g(android.content.Context, android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet, android.content.res.Resources$Theme):b.b.e.a.a");
    }

    public b.b.e.a.b.c b() {
        return new c(this.p, this, null);
    }

    public void e(b.b.e.a.b.c cVar) {
        super.e(cVar);
        if (cVar instanceof c) {
            this.p = (c) cVar;
        }
    }

    public b.b.e.a.d.a f() {
        return new c(this.p, this, null);
    }

    public boolean isStateful() {
        return true;
    }

    public void jumpToCurrentState() {
        super.jumpToCurrentState();
        g gVar = this.q;
        if (gVar != null) {
            gVar.d();
            this.q = null;
            d(this.r);
            this.r = -1;
            this.s = -1;
        }
    }

    public Drawable mutate() {
        if (!this.t) {
            super.mutate();
            if (this == this) {
                this.p.e();
                this.t = true;
            }
        }
        return this;
    }

    public boolean onStateChange(int[] iArr) {
        int[] iArr2 = iArr;
        c cVar = this.p;
        int g = cVar.g(iArr2);
        if (g < 0) {
            g = cVar.g(StateSet.WILD_CARD);
        }
        int i = this.g;
        boolean z = false;
        if (g != i) {
            Object obj;
            g gVar = this.q;
            if (gVar != null) {
                if (g != this.r) {
                    if (g == this.s && gVar.a()) {
                        gVar.b();
                        this.r = this.s;
                        this.s = g;
                    } else {
                        i = this.r;
                        gVar.d();
                    }
                }
                obj = 1;
                if (obj != null || d(g)) {
                    z = true;
                }
            }
            this.q = null;
            this.s = -1;
            this.r = -1;
            c cVar2 = this.p;
            int i2 = cVar2.i(i);
            int i3 = cVar2.i(g);
            if (!(i3 == 0 || i2 == 0)) {
                int longValue = (int) ((Long) cVar2.K.f(c.h(i2, i3), Long.valueOf(-1))).longValue();
                if (longValue >= 0) {
                    g eVar;
                    boolean z2 = (((Long) cVar2.K.f(c.h(i2, i3), Long.valueOf(-1))).longValue() & 8589934592L) != 0;
                    d(longValue);
                    Drawable drawable = this.c;
                    if (drawable instanceof AnimationDrawable) {
                        eVar = new e((AnimationDrawable) drawable, (((Long) cVar2.K.f(c.h(i2, i3), Long.valueOf(-1))).longValue() & 4294967296L) != 0, z2);
                    } else if (drawable instanceof b.s.a.a.b) {
                        eVar = new d((b.s.a.a.b) drawable);
                    } else if (drawable instanceof Animatable) {
                        eVar = new b((Animatable) drawable);
                    }
                    eVar.c();
                    this.q = eVar;
                    this.s = i;
                    this.r = g;
                    obj = 1;
                    z = true;
                }
            }
            obj = null;
            z = true;
        }
        Drawable drawable2 = this.c;
        return drawable2 != null ? z | drawable2.setState(iArr2) : z;
    }

    public boolean setVisible(boolean z, boolean z2) {
        boolean visible = super.setVisible(z, z2);
        g gVar = this.q;
        if (gVar != null && (visible || z2)) {
            if (z) {
                gVar.c();
            } else {
                jumpToCurrentState();
            }
        }
        return visible;
    }

    public a(c cVar, Resources resources) {
        super(null);
        this.r = -1;
        this.s = -1;
        c cVar2 = new c(cVar, this, resources);
        super.e(cVar2);
        this.p = cVar2;
        onStateChange(getState());
        jumpToCurrentState();
    }
}
